# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=process-cpp
pkgver=3.0.1
pkgrel=8
pkgdesc="A simple convenience library for handling processes in C++11"
url="https://gitlab.com/ubports/core/lib-cpp/process-cpp"
arch="all"
license="LGPL-3.0-only"
depends_dev="properties-cpp-dev"
makedepends="$depends_dev cmake cmake-extras boost-dev gtest-dev samurai"
subpackages="$pkgname-dev"
source="https://gitlab.com/ubports/core/lib-cpp/process-cpp/-/archive/$pkgver/process-cpp-$pkgver.tar.gz
	0001-Musl-libc-fixes.patch
	cxx17.patch
	no-execinfo.patch
	gcc12.patch
	"
options="!check" # Tests are randomly failing

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DPROCESS_CPP_ENABLE_DOC_GENERATION=OFF \
		-DPROCESS_CPP_WERROR=OFF \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "linux_process_test"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
4a96d57ea211a264f088c3bebd42a8a5603ed6652d7731ff9b05190c2c71b4e4c9e65164475530fbe5cf6a77f6441cf92b00680ea61b9274a91921bb76c11e88  process-cpp-3.0.1.tar.gz
e9ce9aba66437fe1aea61cf06bca837194b1709acb3105fb452714f4e883158369bf501dd6658e8fa75779e390896b61b6824f2ae4512343519eca524e049e4b  0001-Musl-libc-fixes.patch
752416364e0546151e0fbc343cb38bde2654164211fc9915a3bfe549447d3dcda5be8b02305ca82b8bc6f94a971c15aa66b10383a28f342cf86fe1985762cb3c  cxx17.patch
28fae27ccf65e34228aa44986143e0312e7a7a84c587018df4037ce83dae0c32accca2df74b34d86d038dd51490f4a4e75081e8a9254ebda1390ff73d4889d1c  no-execinfo.patch
15f47d9e1c6333f7861e535804f9bcc530bba47e7717a635a5720da39cce0f198867b577e95f42b9f1014e82e43deceabfe137e80eb9c8984945b0c4646c4362  gcc12.patch
"
